from django.urls import path
from . import views

app_name = 'core'

urlpatterns = [
    # ============ 页面视图 ============
    path('', views.dashboard, name='dashboard'),
    path('dashboard/', views.dashboard, name='dashboard'),
    path('upload/', views.data_upload, name='data_upload'),

    path('tasks/', views.task_list, name='task_list'),
    path('tasks/<int:task_id>/', views.task_detail, name='task_detail'),
    path('files/', views.file_manager, name='file_manager'),
    # Template views moved to apps.template_management.urls
    path('data-generation/', views.data_generation, name='data_generation'),
    
    # ============ API视图 ============
    
    # 文件上传API

    
    # 任务管理API
    path('api/tasks/', views.TaskAPIView.as_view(), name='api_task_list'),
    path('api/tasks/<int:task_id>/', views.TaskAPIView.as_view(), name='api_task_detail'),
    path('api/tasks/<int:task_id>/cancel/', views.cancel_task, name='api_cancel_task'),
    path('api/tasks/<int:task_id>/retry/', views.retry_task, name='api_retry_task'),
    
    # 文件管理API
    path('api/files/', views.FileAPIView.as_view(), name='api_file_list'),
    path('api/files/<int:file_id>/', views.FileAPIView.as_view(), name='api_file_detail'),
    path('api/files/<int:file_id>/download/', views.download_file, name='api_download_file'),
    path('api/files/<int:file_id>/preview/', views.preview_file, name='api_preview_file'),
    
    # 仪表板API
    path('api/dashboard/stats/', views.dashboard_stats, name='api_dashboard_stats'),
    
    # 模板API
    path('api/templates/', views.template_list, name='api_template_list'),
]